package com.dcy.znoa.dao.attendance;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.dcy.znoa.controller.attendance.model.apply.SelectApplyModel;
import com.dcy.znoa.controller.attendance.model.apply.SelectApplyNum;
import com.dcy.znoa.controller.attendance.model.apply.SendApplyModel;
import com.dcy.znoa.controller.attendance.model.attRealRecord.QueryOpersByApplyTypeModel;
import com.dcy.znoa.controller.attendance.model.attRealRecord.QueryOpersByAttTypeModel;
import com.dcy.znoa.controller.publiz.model.messNotice.AddMessNoticeListModel;
import com.dcy.znoa.controller.publiz.model.oper.BatchValidOperModel;
import com.dcy.znoa.controller.publiz.model.oper.SelectOperModel;
import com.dcy.znoa.domain.Oper;
import com.dcy.znoa.domain.attendance.Apply;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface ApplyDao extends BaseMapper<Apply>{

    List selectListMapper(SelectApplyModel model, Page page);

    List queryReasonList(SelectApplyModel model,Page page);

    List queryOpersByAttType(QueryOpersByAttTypeModel model,Page page);

    List queryOpersByApplyType(QueryOpersByApplyTypeModel model,Page page);

//    List selectSendAndReceiveNumByOperId(Long operId);
    SelectApplyNum selectSendAndReceiveNumByOperId(SendApplyModel model);
/**
 <select id="selectListMapper" parameterType="com.dcy.znoa.controller.attendance.model.apply.SelectApplyModel" resultType="com.dcy.znoa.domain.attendance.Apply">
 SELECT app.apply_id ,app.comp_id ,app.e_name ,app.e_id,app.send_oper_id,app.receive_oper_id,app.is_final,app.apply_time,app.start_time,
 app.end_time,app.child_type,app.title,app.content,app.remark,app.address,app.audit_time,
 app.audit_content,app.is_revoke,app.valid_flag,
 cp.comp_name,so.oper_name,so.phone_no,app.type,
 so1.oper_name AS receive_oper_name,so1.head_pic as receive_head_pic,
 CASE app.type
 WHEN 1 THEN '请假'
 WHEN 2 THEN '出差'
 WHEN 3 THEN '外勤'
 WHEN 9 THEN '申述'
 ELSE '其他' END AS type_str,
 TIMESTAMPDIFF(HOUR ,app.start_time,app.end_time) as diff,
 app.is_audit,
 CASE app.is_audit
 WHEN 0 THEN '未审核'
 WHEN 1 THEN '已通过'
 WHEN 2 THEN '未通过'
 ELSE '其他' END AS is_audit_str
 FROM apply app
 left JOIN company cp on app.comp_id = cp.duty_id
 left JOIN sys_oper so on app.send_oper_id = so.oper_id
 left JOIN sys_oper so1 on app.receive_oper_id = so1.oper_id
 left JOIN duty sd on so.duty_id = sd.duty_id
 left JOIN department d on so.dep_id = d.dep_id
 <where>
 <if test="compId!=null"><![CDATA[AND app.comp_id = #{compId}]]></if>
 <if test="sendOperId!=null"><![CDATA[AND app.send_oper_id = #{sendOperId}]]></if>
 <if test="sendOperName!=null"><![CDATA[AND so.oper_name LIKE concat('%',#{sendOperName},'%')]]></if>
 <if test="type!=null"><![CDATA[AND app.type = #{type}]]></if>
 <if test="isAudit!=null"><![CDATA[AND app.is_audit = #{isAudit}]]></if>
 <if test="dutyId!=null"><![CDATA[AND so.duty_id = #{dutyId}]]></if>
 <if test="st!=null"><![CDATA[AND app.apply_time >= #{st}]]></if>
 <if test="et!=null"><![CDATA[AND app.apply_time <= #{et}]]></if>
 </where>
 ORDER BY app.apply_time DESC
 </select>

 <select id="queryReasonList" parameterType="com.dcy.znoa.controller.attendance.model.apply.SelectApplyModel" resultType="com.dcy.znoa.domain.attendance.Apply">
 SELECT app.apply_id ,app.comp_id ,app.e_name ,app.e_id,app.send_oper_id,app.receive_oper_id,app.is_final,app.apply_time,app.start_time,
 app.end_time,app.child_type,app.title,app.content,app.remark,app.address,app.audit_time,
 app.audit_content,app.is_revoke,app.valid_flag,
 cp.comp_name,so.oper_name,so.phone_no,app.type,
 so1.oper_name AS receive_oper_name,so1.head_pic as receive_head_pic,
 CASE app.type
 WHEN 1 THEN '请假'
 WHEN 2 THEN '出差'
 WHEN 3 THEN '外勤'
 WHEN 9 THEN '申述'
 ELSE '其他' END AS type_str,
 TIMESTAMPDIFF(HOUR ,app.start_time,app.end_time) as diff,
 app.is_audit,
 CASE app.is_audit
 WHEN 0 THEN '未审核'
 WHEN 1 THEN '已通过'
 WHEN 2 THEN '未通过'
 ELSE '其他' END AS is_audit_str,
 arr.record_type,arr.record_time,arr.time_status,arr.add_status,arr.address
 FROM apply app
 INNER JOIN att_real_record arr on app.e_id = arr.record_id
 left JOIN company cp on app.comp_id = cp.duty_id
 left JOIN sys_oper so on app.send_oper_id = so.oper_id
 left JOIN sys_oper so1 on app.receive_oper_id = so1.oper_id
 left JOIN duty sd on so.duty_id = sd.duty_id
 left JOIN department d on so.dep_id = d.dep_id
 <where>
 app.type = 9
 <if test="compId!=null"><![CDATA[AND app.comp_id = #{compId}]]></if>
 <if test="sendOperId!=null"><![CDATA[AND app.send_oper_id = #{sendOperId}]]></if>
 <if test="sendOperName!=null"><![CDATA[AND so.oper_name LIKE concat('%',#{sendOperName},'%')]]></if>
 <if test="type!=null"><![CDATA[AND app.type = #{type}]]></if>
 <if test="isAudit!=null"><![CDATA[AND app.is_audit = #{isAudit}]]></if>
 <if test="dutyId!=null"><![CDATA[AND so.duty_id = #{dutyId}]]></if>
 <if test="st!=null"><![CDATA[AND app.apply_time >= #{st}]]></if>
 <if test="et!=null"><![CDATA[AND app.apply_time <= #{et}]]></if>
 </where>
 ORDER BY app.apply_time DESC
 </select>

 </mapper>

 */

}
